// Copyright (C) 2025 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@import "../common";

.pf-exp-filters-header {
  display: flex;
  align-items: center;
  gap: 1rem;

  .pf-exp-filters-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
  }
}

// Filter chip wrapper for enabled/disabled state
.pf-filter-chip-wrapper {
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;

  // Override chip's min-width to allow shrinking
  .pf-chip {
    min-width: 0;
    max-width: 100%;
  }

  &--disabled {
    opacity: 0.5;
    text-decoration: line-through;
  }

  &--compact {
    font-size: 11px;
  }
}

// Operator header for filter lists (AND/OR badge)
.pf-filter-operator-header {
  margin-bottom: 4px;
}

// Enabled count indicator
.pf-filter-enabled-count {
  font-size: 11px;
  color: #9e9e9e;
  margin-bottom: 4px;
  margin-top: 4px;
}

// Filter chips container
.pf-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 250px;

  &--with-count {
    margin-top: 4px;
  }

  &--no-count {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;

    &.pf-filter-chips--compact {
      gap: 2px;
    }
  }

  &--compact {
    gap: 2px;
  }
}

// Filter container base
.pf-filter-container {
  max-width: 250px;
  box-sizing: border-box;
  overflow: visible;
}

// AND filters header
.pf-filter-and-header {
  margin-bottom: 8px;
  font-size: 11px;
  color: #616161;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

// AND/OR operator badge
.pf-filter-operator-badge {
  background-color: var(--pf-color-background-secondary);
  color: var(--pf-color-text-muted);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

// OR group container for nodeDetails and nodeSpecificModify
.pf-or-group-container {
  display: flex;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--primary-color, #4a90e2);
  border-radius: 8px;
  background-color: var(
    --primary-background-transparent,
    rgba(74, 144, 226, 0.05)
  );
  margin-top: 8px;
  margin-bottom: 8px;

  &--disabled {
    opacity: 0.5;
  }
}

.pf-or-group-label {
  font-weight: bold;
  font-size: 14px;
  color: var(--primary-color, #4a90e2);
  min-width: 30px;
  display: flex;
  align-items: center;
}

.pf-or-group-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0; // Allow flexbox to shrink below content size
  overflow: hidden;

  &--compact {
    gap: 2px;
  }
}

.pf-or-group-controls {
  display: flex;
  align-items: center;
}

// Filters container with separator
.pf-filters-container {
  border-top: 1px solid var(--stroke-color, #e0e0e0);
  padding-top: 12px;
  margin-top: 12px;
}

// Filter container with groups support
.pf-filter-container--with-groups {
  .pf-filter-chips {
    display: flex;
    flex-direction: column;
    gap: 4px;

    &--compact {
      gap: 2px;
    }
  }
}

// Query operations container spacing
.pf-exp-query-operations {
  margin-top: 16px;
}

// Filter mode help text
.pf-exp-filter-mode-help {
  margin-bottom: 16px;
  padding: 8px 12px;
  background-color: rgba(74, 144, 226, 0.08);
  border-left: 3px solid var(--primary-color, #4a90e2);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-primary, #333);
  line-height: 1.4;
}

// Filter node content container
.pf-filter-node-content {
  display: flex;
  flex-direction: column;
  width: 100%;
}

// Filter input options (Create filter button + text input)
.pf-filter-input-options {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 8px 0;
}

// Separator between filter options
.pf-filter-or-separator {
  color: var(--md-sys-color-outline);
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

// Type filter text input container
.pf-filter-type-input {
  justify-self: end;
  width: 100%;
  max-width: 280px;

  // Make the text input fill the container
  .pf-text-input {
    width: 100%;
  }
}

// Filter list container
.pf-filters-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

// Disabled filter styling
.pf-filter-disabled {
  opacity: 0.5;
}

// Filter footer with operator toggle and mode switch
.pf-filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

// SQL expression modal editor container
.pf-filter-sql-editor {
  min-height: 300px;
  // Matches the One Dark theme used by the CodeMirror editor
  background-color: var(--pf-editor-background, #282c34);
  position: relative;
}
